import { createApp } from 'vue'
import App from '@/App.vue'
import router from '@/router'
import ElementPlus from 'element-plus'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import 'element-plus/dist/index.css'
import '@/assets/styles/theme.css'  // 引入全局主题
import { createPinia } from 'pinia'
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
import { usePlayerStore } from '@/store'

const app = createApp(App)

// 注册所有图标
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}

app.use(ElementPlus)
app.use(router)

const pinia = createPinia()
// 添加持久化插件
pinia.use(piniaPluginPersistedstate)
app.use(pinia)

// 确保播放器初始化为暂停状态
const playerStore = usePlayerStore()
playerStore.ensurePaused()

app.mount('#app')
